#ifndef MAPWIDGET_H
#define MAPWIDGET_H

#include <QWidget>
#include <QPixmap>
#include <QPoint>
#include <QList>
#include <QStringList>
#include <QButtonGroup>
#include "qcustomplot.h"
#include "stationpoint.h"
#include "car.h"
#include "bspline.h"

namespace Ui {
class MapWidget;
}

class MapWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MapWidget(QWidget *parent = 0);
    ~MapWidget();

private:
    Ui::MapWidget *ui;
    QCPCurve* pathPos;
    QCPGraph *graphBlock;
    QPixmap map;
    QString basePath;
    Car* car;
    bool global_view;
    QButtonGroup group_station;
//    QList<QPointF> list_point;
    QList<StationPoint*> list_station;
    QVector<QPointF> list_path;
    bool needFindeStation;
    int nextIndex;
    qreal disToNextStation;

    void readPathPoint(QString fileName);
    void readStationPoint(QString fileName);
    void clearStations();
    void checkStation(QPointF p);//check pass or not
    void initStationState();
    void findStation(QPointF p);
    void mapUpdate();
    void mapRescale(bool isGlobalView);
    int findPointIndex(QPointF p);
    QString getPathFileName();
    QString getStationFileName();
    void initBlockGraph();
    void setBlockData(QStringList blocks);

signals:
    void gotoPos(QPointF, int);

public slots:
    void setGlobalView(bool);//变换全局视角和小车视角
    void recvCarPos(QPointF, int ang);//接收小车坐标
    void recvBlockPos(QStringList blockInfo);
    void updatePath();//更新路径
    void updateStation();//更新站点
};

#endif // MAPWIDGET_H
